import Head from "../conent/header_register.js"
import store from "../../store/store";
import {Router,Route,hashHistory,IndexRedirect} from "react-router";

export default React.createClass({
	Sg:function(e){
		e.preventDefault()
		var Ouser = this.refs.user.value
		var Opas = this.refs.pas.value 
		//获取本地数据
		for(var i=0;i<localStorage.length;i++){
			//对账号先判断
			if(Ouser == localStorage.key(i)){
				//账号正确判断密码
				if(Opas == localStorage.getItem(localStorage.key(i))){
					$(".one_ti").text("登录成功,正在跳转!!")
					$(".one_ti").css({display:"block"})
					//创建一个流浪器存储当前登录状态,当浏览器关闭重新登录
					var userobj = {
						user : this.refs.user.value,
						pas : this.refs.pas.value
					}
					userobj = JSON.stringify(userobj)
					sessionStorage.setItem("ZT",userobj) 
					//1s后跳转到跟人主页
					var that = this
					setTimeout(function(){
						hashHistory.push("isme")
					},1000)
				}else{
					$(".one_ti").text("密码不存在")
					$(".one_ti").css({display:"block"})
					hashHistory.push("sign")
				}
			}else{
				$(".one_ti").text("账号不正确或不存在")
				$(".one_ti").css({display:"block"})
				hashHistory.push("sign")
				$("body").click(function(){
					$(".one_ti").css({display:"none"})
					
				})
			}
		}
		
	},
	render: function() {
		return(
			<div className="sign_user">
				<Head data={"登录"} data2={"注册"} data3={"register/ptuser"}/>
				<div className ="qq">
					<p>合作伙伴登录</p>
					<div>茶窝网账号登录</div>
					<h1></h1>
					<h2></h2>
					<a className="iconfont qq_aa icon-icon_caiseqq"></a>
				</div>
				<form onSubmit={this.Sg}>
					<div className="pt_user_cls">
					<section>
						<span>账&nbsp;&nbsp;&nbsp;&nbsp;号</span>
						<input type="text" placeholder="请输入用户名/验证手机号" ref="user"/>
						<b>×</b>
					</section>
					<section>
						<span>密&nbsp;&nbsp;&nbsp;&nbsp;码</span>
						<input type="password" placeholder="请输入登录密码" ref="pas"  />
						<b>×</b>
					</section>
					</div>
					<div className="user_xieyi">
								<span onClick={this.que} id="que">√</span>30天自动登录<a id="wj_mi">忘记密码 ?</a>
					</div>
					<input type="submit" defaultValue="登录" className="pt_sub"/>
					<div className="one_ti"></div>
				</form>
			</div>
		)
	}
})